let Utils = require("../../framework/js/utils");

require("../../framework/js/aui/components/table.component");
require("./ui_9/datatable");

module.exports = {
    template: `
        <div class="anu-subpage" style="width: 100%;">   
            <button class="btn btn-info" type="button" @click="search">搜索</button>
            <ui-9-datatable ref="table"
            @aftersetdata="loadDataDone"
            ></ui-9-datatable>
        </div>
    `,
    data() {
        var ret = {};
        ret.datatableRules = window.AUI.customCompoents.get("aui-table").defineRules({
            "create_time": "创建时间",
            "promo_name": "推广位名称",
            "sid": "推广代码",
            "category_name": "分类",
            "product_name": "产品",
            "remark": rootcontroller.globaldata.gloablDatatableDefine["remark"],
        });
        return ret;
    },
    mounted() {
        var self = this;
        self.$refs.table.setRules(self.datatableRules);
        self.$refs.table.requestMethods = function (page) {
            console.dir(page);
            return new Promise(function (resolve, reject) {
                resolve({
                    data: {
                        data: [
                            {}
                        ]
                    }
                });
            });
        };
        rootcontroller.getPage(self).attachChildComponentReady();
    },
    methods: {
        service() {
        },
        search() {
            this.$refs.table.refresh(1).then(function (table, response, data) {
                table.setPagination({
                    perPage: 10,
                    currentPage: 1,
                    pageCount: 3
                });
            });
        },
        loadDataDone(table, response, data) {
            console.log("load done");
        },
        onError(e) {
            console.log('-------------------');
            console.log(e);
            console.log('-------------------');
        }
    }
};